<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>后台管理 - 易买网</title>
	<link type="text/css" rel="stylesheet" href="../css/style.css"/>

	<script type="text/javascript" src="../scripts/jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="../scripts/function.js"></script>
	<script type="text/javascript" src="../plugins/axios/axios.min.js"></script>
	<script type="text/javascript" src="../scripts/request.js"></script>
	<!-- 引入样式 -->
	<link rel="stylesheet" href="../plugins/element-ui/element-ui.css">
	<!--设置分页插件颜色-->
	<style type="text/css">
		.pager > * {
			float: right;
		}

		.clearfix.is-background .el-pager li:not(.disabled).active {
			/*点击背景变成橙色*/
			background-color: #fc7e31;
		}

		.clearfix.is-background .el-pager li:hover {
			/*鼠标经过字变橙色*/
			color: #fc7e31 !important;
		}

		.clearfix.is-background .el-pager li.active {
			/*鼠标经过选中的字是白色*/
			color: white !important;
		}

		.el-select-dropdown__item.selected {
			color: #fc7e31 !important; /* 设置选中条目的背景色 */
		}

		.el-select .el-input.is-focus .el-input__inner {
			border-color: #ddc9b2 !important;
		}

		.el-pagination__sizes .el-input .el-input__inner:hover {
			border-color: #ddc9b2 !important;
		}

		.el-input__inner:focus {
			border-color: #ddc9b2 !important;
		}
	</style>
</head>
<body>
<div id="app">
	<div id="header" class="wrap">
		<div id="logo"><img src="../images/logo.gif"/></div>
		<div class="help"><a href="../index.html">返回前台页面</a></div>
		<div class="navbar">
			<ul class="clearfix">
				<li><a href="index.html">首页</a></li>
				<li class="current"><a href="user.html">用户</a></li>
				<li><a href="product.html">商品</a></li>
				<li><a href="order.html">订单</a></li>
				<li><a href="guestbook.html">留言</a></li>
				<li><a href="news.html">新闻</a></li>
			</ul>
		</div>
	</div>
	<div id="childNav">
		<div class="welcome wrap">
			管理员{{ userId }}您好，今天是{{ time }}，欢迎回到管理后台。
		</div>
	</div>
	<div id="position" class="wrap">
		您现在的位置：<a href="index.html">易买网</a> &gt; 管理后台
	</div>
	<div id="main" class="wrap">
		<div id="menu-mng" class="lefter">
			<div class="box">
				<dl>
					<dt>用户管理</dt>
					<dd><a href="user.html">用户管理</a></dd>
					<dt>商品信息</dt>
					<dd><em><a href="productClass-add.html">新增</a></em><a href="productClass.html">分类管理</a></dd>
					<dd><em><a href="product-add.html">新增</a></em><a href="product.html">商品管理</a></dd>
					<dt>订单管理</dt>
					<dd><a href="order.html">订单管理</a></dd>
					<dt>留言管理</dt>
					<dd><a href="guestbook.html">留言管理</a></dd>
					<dt>新闻管理</dt>
					<dd><em><a href="news-add.html">新增</a></em><a href="news.html">新闻管理</a></dd>
				</dl>
			</div>
		</div>
		<div class="main" v-loading="loading">
			<h2 style="cursor: pointer" onclick="window.location.href='index.html'">用户管理</h2>
			<div class="manage">
				<table class="list">
					<tr>
						<th>用户名</th>
						<th>真实姓名</th>
						<th>性别</th>
						<th>Email</th>
						<th>手机</th>
						<th>操作</th>
					</tr>
					<tr v-for="item in userList" :key="item.userId">
						<td class="first w4 c">{{ item.userId }}</td>
						<td class="w1 c">{{ item.username }}</td>
						<td class="w2 c" v-if="String(item.sex) === '1'">男</td>
						<td class="w2 c" v-else>女</td>
						<td>{{ item.email }}</td>
						<td class="w4 c">{{ item.mobile }}</td>
						<td class="w1 c">
							<a :href=`user-modify.html?id=${item.id}`>修改</a>
							<a class="manageDel" @click="remove(item.id)" href="#">删除</a>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="clear"></div>
		<div class="pager">
			<el-pagination
					class="clearfix"
					background
					@size-change="handleSizeChange"
					@current-change="handleCurrentChange"
					:page-sizes="[2, 5, 10, 15]"
					layout="sizes, prev, pager, next, jumper"
					:current-page="page.currentPage"
					:page-size="page.pageSize"
					:total="page.total">
			</el-pagination>
			<br>
		</div>
	</div>
	<div id="footer">
		Copyright &copy; 2013 北大青鸟 All Rights Reserved. 京ICP证1000001号
	</div>
</div>

<script type="text/javascript" src="../plugins/vue/vue.js"></script>
<script type="text/javascript" src="../api/user.js"></script>
<script type="text/javascript" src="../api/common.js"></script>
<script type="text/javascript" src="../plugins/element-ui/element-ui.js"></script>
<script type="text/javascript">
	axios.get("/user/getStatus")
	const app = new Vue({
		el: '#app',
		data: {
			userList: [],
			page: {
				currentPage: 1,
				pageSize: 5,
				total: 100,
				name: ''
			},
			loading: false,
			userId: getUserInfo().userId,
			time: getFormattedDate()
		},
		async mounted() {
			await this.getPageList();
		},
		methods: {
			async getPageList() {
				this.loading = true
				const list = await pageApi(this.page.currentPage, this.page.pageSize, this.page.name);

				console.log(list)
				this.page.total = list.data.total

				this.userList = list.data.records
				this.loading = false
			},
			async handleCurrentChange(page) {
				this.page.currentPage = page;
				await this.getPageList();
			},
			async handleSizeChange(size) {
				this.page.pageSize = size;
				await this.getPageList();
			},
			async remove(id) {
				if(confirm("确认要删除此用户吗？")){
					const del = await delApi(id)
					console.log(del)
					if (del.code === 1) {
						this.$message({
							message: '删除成功',
							type: 'success'
						});
					}
					await this.getPageList()
				}

			}
		}
	})
</script>
</body>
</html>
